package kr.ac.kongju.gedl.cmmn.web;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import org.springframework.context.ApplicationContext;
/**
 * context를 쉽게 호출하여 사용 할 수 있는 context manager
 * @author INCE_G27K
 *
 */
public class SpringContextManager {
	
	protected final ReadWriteLock lock = new ReentrantReadWriteLock();
	
	private ApplicationContext context;
	
	private static class SpringContextManagerHolder {
		private static SpringContextManager manager = new SpringContextManager();
	}
	
	public static SpringContextManager getInstance() {
		return SpringContextManagerHolder.manager;
	}

	public ApplicationContext getContext() {
		lock.readLock().lock();
		try {
		return this.context;
		} finally {
			lock.readLock().unlock();
		}
	}

	public void setContext(ApplicationContext context) {
		lock.readLock().lock();
		try {
		this.context = context;
		} finally {
			lock.readLock().unlock();
		}
	}
	
}
